from os import listdir
from os.path import isfile, join
import os
import pathlib

if __name__ == "__main__":
    path=str(input("请输入你要去除换行的目录: "))
    filenames = [f for f in listdir(path) if isfile(join(path, f))]
    for filename in filenames:
        content = ""
        file_path = os.path.abspath(str(path) + '/' + filename)
        print(file_path)
        with open(file_path, 'r', encoding='utf-8') as rf:
            for line in rf.readlines():
                temp = line.strip();
                if temp.split():
                    if (temp.startswith('<')) or (temp.endswith('>')):
                        line = line.strip()
                    content += line
                else:
                    content += line
                
        with open(file_path, 'w', encoding='utf-8') as wf:		
            wf.write(content)
			